// menu.ts
import { LogicalPosition } from '@tauri-apps/api/window';
import { Menu } from '@tauri-apps/api/menu';
import { controlWindow } from './window';
(async () => {
    const menu = await Menu.new({
        items: [
            {
                id: 'main-quit',
                text: '关闭窗口',
                action: async () => {
                    await controlWindow('bp-frontend','close');
                    await controlWindow('bp-transition','close');
                    // 主窗口一定要最后关闭！
                    await controlWindow('bp-backend','close');
                },
            },
            {
                id: 'main-mini',
                text: '最小化',
                action: async () => {
                    await controlWindow('bp-backend','minimize');
                },
            },
        ],
    });
    await menu.setAsAppMenu();

    window.addEventListener('contextmenu', async (event) => {
        event.preventDefault();
        menu.popup(new LogicalPosition(event.clientX, event.clientY));
    });
})();